'use strict';

const ora = require('ora');
const chalk = require('chalk');

module.exports = (fn, message) => async (...rest) => {
  try {
    const spinner = ora(`${message}\n`);
    spinner.start();
    const result = await fn(...rest);
    spinner.succeed();
    return result;
  } catch (err) {
    console.log(chalk.red.dim(`${err}\n`))
    process.exit();
  }
};
